# 场景：你想要“写起来像线程池、跑起来像多进程”
from concurrent.futures import ProcessPoolExecutor
import time

def cpu_heavy(x):
    print(f"开始处理：{x}")
    time.sleep(2)
    return x * x

if __name__ == '__main__':
    with ProcessPoolExecutor(max_workers=3) as executor:
        futures = [executor.submit(cpu_heavy, i) for i in range(3)]
        for f in futures:
            print("结果：", f.result())

    print("处理完成")
